Fix CI test failures: manifest service mocks and I18nLabel schema migration#1065
Fix CI test failures: manifest service mocks and I18nLabel schema migration#1065
Conversation
… assertions This commit fixes 3 packages with failing tests: 1. @objectstack/plugin-setup - Updated I18nLabel assertions from object to string (per schema change) - Pre-registered manifest service in mock context - Changed test assertions to use manifestService.register instead of ctx.registerService 2. @objectstack/plugin-security - Added manifest service mock to all 4 failing test cases - Used mockImplementation pattern to conditionally return manifest service 3. @objectstack/service-ai - Pre-registered manifest service in services Map within createMockContext Root causes: - I18nLabel schema evolved from object (with key/defaultValue) to plain string - Plugins now depend on manifest service for metadata registration - Tests weren't updated to match current implementation patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…ration Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/113908f4-eadd-46c5-b18a-2d12508792dc Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates failing test suites to match the current plugin lifecycle where plugins register metadata via ctx.getService('manifest').register(), and aligns assertions/docs with the I18nLabel schema migration (now a plain string).
Changes:
- Pre-register a
manifestservice in mocked plugin contexts used by tests (setup, security, and service-ai). - Update tests to assert against
manifest.register()calls instead ofctx.registerService()and to treat labels asstring. - Regenerate/update reference docs to reflect
I18nLabel-as-string and related schema surface updates.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/services/service-ai/src/tests/ai-service.test.ts | Pre-registers manifest in the test context’s services map to prevent init/start failures. |
| packages/plugins/plugin-setup/src/setup-plugin.test.ts | Adds manifest mock to context; updates assertions to string labels and manifest.register() calls. |
| packages/plugins/plugin-security/src/security-plugin.test.ts | Adds manifest service mocking in multiple test cases to match plugin init behavior. |
| content/docs/references/ui/widget.mdx | Updates reference tables to show label/description types as string only. |
| content/docs/references/ui/view.mdx | Updates label/placeholder/helpText/description types to string. |
| content/docs/references/ui/touch.mdx | Updates label/ariaLabel types to string. |
| content/docs/references/ui/report.mdx | Updates label/title/subtitle/description types to string. |
| content/docs/references/ui/page.mdx | Updates label/description/component label types to string. |
| content/docs/references/ui/offline.mdx | Updates offlineMessage type to string. |
| content/docs/references/ui/notification.mdx | Updates title/message/label/ariaLabel types to string. |
| content/docs/references/ui/keyboard.mdx | Updates ariaLabel/description types to string. |
| content/docs/references/ui/i18n.mdx | Updates ariaLabel to string and removes the old I18nLabel union documentation block. |
| content/docs/references/ui/dnd.mdx | Updates label/ariaLabel types to string. |
| content/docs/references/ui/dashboard.mdx | Updates label/title/description types to string. |
| content/docs/references/ui/component.mdx | Updates various UI component label/title/subtitle/placeholder types to string. |
| content/docs/references/ui/chart.mdx | Updates label/title/subtitle/description types to string. |
| content/docs/references/ui/app.mdx | Updates label/description types to string across navigation/app/area schemas. |
| content/docs/references/ui/animation.mdx | Updates label/ariaLabel types to string. |
| content/docs/references/ui/action.mdx | Updates action param label type to string. |
| content/docs/references/system/metadata-persistence.mdx | Updates import list and adds new schema sections (diff/history) to the reference doc. |
| content/docs/references/api/protocol.mdx | Documents new optional packageId fields on AI insights request schemas. |
| @@ -23,6 +30,7 @@ function createMockContext() { | |||
| }), | |||
| getService: vi.fn((name: string) => services.get(name)), | |||
There was a problem hiding this comment.
createMockContext()'s getService mock returns undefined for unknown services, but PluginContext.getService() is documented to throw when a service is not found. This can mask bugs and makes the tests less representative of runtime behavior. Consider updating the mock to throw for missing names (and only return known services).
| getService: vi.fn((name: string) => services.get(name)), | |
| getService: vi.fn((name: string) => { | |
| if (!services.has(name)) { | |
| throw new Error(`Service not found: ${name}`); | |
| } | |
| return services.get(name); | |
| }), |
| getService: vi.fn(), | ||
| getService: vi.fn().mockImplementation((name: string) => { | ||
| if (name === 'manifest') return manifestService; | ||
| return undefined; |
There was a problem hiding this comment.
The getService mock returns undefined for unknown services (e.g., in the init test), but PluginContext.getService() is specified to throw when a service is missing. Using a throwing mock here would better match production semantics and ensure the plugin’s try/catch paths are actually exercised as intended.
| return undefined; | |
| throw new Error(`Service not found: ${name}`); |
| | **ariaLabel** | `string` | optional | Accessible label for screen readers (WAI-ARIA aria-label) | | ||
| | **ariaDescribedBy** | `string` | optional | ID of element providing additional description (WAI-ARIA aria-describedby) | | ||
| | **role** | `string` | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") | |
There was a problem hiding this comment.
This page still imports I18nLabel in the TypeScript usage snippet, but the I18nLabel schema section has been removed, leaving no documentation of what I18nLabel is (even if it’s now just a string). Since this file is auto-generated, consider adjusting the docs generator to emit a brief I18nLabel section (or update the usage snippet generation to omit simple aliases that aren’t documented).
Three test suites were failing due to (1) missing manifest service in mock contexts and (2) outdated assertions expecting I18nLabel as objects instead of strings.
Changes
@objectstack/plugin-setup
manifestservice increateMockContext()typeof label === 'object'→typeof label === 'string'ctx.registerService.mock.callstomanifestService.register.mock.calls@objectstack/plugin-security
mockImplementationpattern in 4 test cases@objectstack/service-ai
createMockContext()Pattern
Tests now align with current plugin lifecycle where plugins call
ctx.getService('manifest').register()during initialization.